﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace VehicleMaintenance.Framework
{
    public partial class ListAndViewBaseForm : BaseForm
    {
		#region 辅助类型

		protected enum State
		{
			/// <summary>
			/// 未定义
			/// </summary>
			Null = 0,
			/// <summary>
			/// 添加
			/// </summary>
			Add = 1,
			/// <summary>
			/// 编辑
			/// </summary>
			Edit = 2,
		}

		#endregion 辅助类型

		#region 私有变量及属性

		/// <summary>
		/// 是选择窗口还是维护窗口
		/// </summary>
		protected bool isSelect = true;

		/// <summary>
		/// 当前窗口状态
		/// </summary>
		protected State state = State.Add;

		#endregion 私有变量及属性

        public ListAndViewBaseForm()
        {
            InitializeComponent();

			panel2.Enabled = false;
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                this.ShowInfo(ex.Message);
            }
        }

		#region 保护方法

		/// <summary>
		/// 清空当前窗体的所有数据
		/// </summary>
		/// <param name="con"></param>
		protected void ClearData(Control con)
		{
			foreach (Control item in con.Controls)
			{
				if (item is TextBox)
				{
					((TextBox)item).Clear();
				}
				else if (item is ComboBox)
				{
					((ComboBox)item).SelectedIndex = -1;
				}
				ClearData(item);
			}
		}

		#endregion 保护方法

		private void btnAdd_Click(object sender, EventArgs e)
		{
			this.panel2.Enabled = true;
			this.state = State.Add;			
		}
    }
}
